﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace FileConvert.AsposeOper
{
    /// <summary>
    /// 控件注册
    /// </summary>
    public class AsposeRegister
    {
        #region cells


        public static void Register_Cells()
        {
            try
            {
                var cells = new Aspose.Cells.License();
                cells.SetLicense(AsposeLicense.LStream);
            }
            catch
            { }
        }

        #endregion

        #region word


        public static void Register_Words()
        {
            try
            {
                var words = new Aspose.Words.License();
                if (words.IsLicensed == false)
                {
                    words.SetLicense(AsposeLicense.LStream);
                }
            }
            catch
            {

            }
        }

        #endregion

        #region ppt
        public static void Register_PPT()
        {
            try
            {
                var ppt = new Aspose.Slides.License();
                if (ppt.IsLicensed() == false)
                {
                    ppt.SetLicense(AsposeLicense.LStream);
                }
            }
            catch
            {

            }
        }
        #endregion 

        public static void Register_Pdf()
        {
            try
            {
                if (System.IO.File.Exists("reg.lic") == false)
                {
                    byte[] buffer = System.Convert.FromBase64String(AsposeLicense.Key);
                    using (var fs = new FileStream("reg.lic", FileMode.Create, FileAccess.Write))
                    {
                        fs.Write(buffer, 0, buffer.Length);
                        fs.Flush();
                    }
                }
                var pdf = new Aspose.Pdf.License();
                pdf.SetLicense("reg.lic");
            }
            catch
            {

            }

        }

        public static void Register_Imaging()
        {
            try
            {
                var img = new Aspose.Imaging.License();
                if (img.IsLicensed == false)
                {
                    img.SetLicense(AsposeLicense.LStream);
                }

            }
            catch
            {

            }
        }
    }
}
